package cn.getech.data.metadata.controller.change;

import cn.getech.data.intelligence.common.utils.BaseRes;
import cn.getech.data.intelligence.common.utils.DataRes;
import cn.getech.data.intelligence.common.utils.PageRes;
import cn.getech.data.intelligence.common.utils.PageUtils;
import cn.getech.data.metadata.entity.CollectionTaskAlarm;
import cn.getech.data.metadata.entity.meta.CollectionTableInfo;
import cn.getech.data.metadata.model.req.change.CollectionTaskAlarmReq;
import cn.getech.data.metadata.service.CollectionTaskAlarmService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description: 源数据采集变更通知
 * @Author: chenshiyang
 * @Date: 2021/8/12 18:05
 */
@Api(value="源数据采集变更通知",tags={"源数据采集变更通知"})
@RestController
@RequestMapping("md/metadataChange")
public class MetadataChangeController {


    @Resource
    CollectionTaskAlarmService collectionTaskAlarmService;

    @ApiOperation("元数据变更通知列表")
    @PostMapping("/list")
    public PageRes<IPage<CollectionTaskAlarm>> list(@RequestBody CollectionTaskAlarmReq req){
        IPage<CollectionTaskAlarm> page = collectionTaskAlarmService.listBy(req);
        return BaseRes.okWithPage(page);
    }

    @ApiOperation("元数据变更通知信息")
    @GetMapping("/info")
    public DataRes<CollectionTaskAlarm> info(@RequestParam("id") Long id){
        CollectionTaskAlarm collectionTaskAlarm = collectionTaskAlarmService.getInfo(id);
        return BaseRes.okWithData(collectionTaskAlarm);
    }

    @ApiOperation("新增元数据变更通知信息")
    @PostMapping("/add")
    public DataRes<CollectionTableInfo> add(@RequestBody CollectionTaskAlarm req){
        collectionTaskAlarmService.add(req);
        return DataRes.okWithData(null);
    }

    @ApiOperation("修改元数据变更通知信息")
    @PostMapping("/update")
    public DataRes<CollectionTableInfo> update(@RequestBody CollectionTaskAlarm req){
        collectionTaskAlarmService.upd(req);
        return DataRes.okWithData(null);
    }

    @ApiOperation("删除元数据变更通知信息")
    @GetMapping("/delete")
    public DataRes<CollectionTableInfo> delete(@RequestParam("id") Long id){
        collectionTaskAlarmService.del(id);
        return DataRes.okWithData(null);
    }

}
